package cn.bdqn.pn.reposity.user;

import cn.bdqn.pn.pojo.user.Resource;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ResourceReposity extends JpaRepository<Resource,Integer>, JpaSpecificationExecutor<Resource>{
/*
     * 根据id
     * @param adminId
     * @return
*/

    @Query(value = "SELECT rs.resourceurl FROM role_resource AS rr " +
            "INNER JOIN resource AS rs ON rr.resourceid = rs.resourceid " +
            "INNER JOIN role AS r ON rr.roleId = r.roleId " +
            "INNER JOIN admin AS a ON a.roleId = r.roleId WHERE a.adminId = :adminId ", nativeQuery = true)
    List<String> findByAdminId(@Param("adminId") Integer adminId);


}
